package cn.lijiancn01.demo.framework.config.mybatis;

import cn.dev33.satoken.stp.StpUtil;
import cn.lijiancn01.demo.framework.model.BaseDO;
import com.mybatisflex.annotation.UpdateListener;

import java.time.LocalDateTime;

public class MyUpdateListener implements UpdateListener {
    @Override
    public void onUpdate(Object entity) {
        if (entity instanceof BaseDO baseDO) {
            //设置 account 被新增时的一些默认数据
            baseDO.setUpdateTime(LocalDateTime.now());
            baseDO.setUpdater(StpUtil.getLoginId().toString());
        }
    }
}
